﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using B10.Models;

namespace B10.Helpers
{
    public class B10RoleProvider : SqlRoleProvider
    {
        IDatabaseRepository _db;

        public B10RoleProvider(IDatabaseRepository db)
        {
            _db = db;
        }

        public B10RoleProvider()
            :this(new DatabaseRepository())
        {

        }

        public override string[] GetRolesForUser(string username)
        {
            UserProfile p = _db.GetProfile(UserHelper.UserId);
            if (p != null)
                return base.GetRolesForUser(p.UserName);
            return new string[] {};
        }

        public override bool IsUserInRole(string username, string roleName)
        {
            UserProfile p = _db.GetProfile(UserHelper.UserId);
            if (p != null)
                return base.IsUserInRole(p.UserName, roleName);
            return false;
        }


      
    }
}
